//Scala编程实战 P255
//【可变集合】中的常用操作符

import scala.collection.mutable.ListBuffer

object collection10031 extends App {

  var list01 = ListBuffer[Int](1, 2, 3, 4, 5)
  val list02 = ListBuffer[Int](6, 7, 8)
  var list03 = ListBuffer[Int](1, 2, 3, 4, 5)
  val list04 = ListBuffer[Int](6, 7, 8)
  var list05 = ListBuffer[Int](1, 2, 3, 4, 5)
  val list06 = ListBuffer[Int](1, 2, 3, 4, 5)
  val list07 = ListBuffer[Int](1, 2, 3, 4, 5)
  val list08 = ListBuffer[Int](1, 2, 3, 4, 5)

  println(list01 += 6) //ListBuffer(1, 2, 3, 4, 5, 6)
  println(list01 += (6, 7, 8)) //ListBuffer(1, 2, 3, 4, 5, 6, 6, 7, 8)
  println(list01 ++= list02) //ListBuffer(1, 2, 3, 4, 5, 6, 6, 7, 8, 6, 7, 8)

  println(list03 -= 2) //ListBuffer(1, 3, 4, 5)
  println(list03 -= (1, 2, 3)) //ListBuffer(4, 5)
  println(list03 --= list04) //ListBuffer(2, 3, 5, 6, 6, 7, 8, 6, 7, 8)

  println(list05(2) = 10)
  println(list06 clear())
  println(list07 remove(2)) //3
  println(list08 remove(1,1))

}
